﻿/*
 *  File: CGetHotelURLs.cs
 *  --------------------- 
 *  This class returns the number of hotels in Vietnam. 
 * 
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DataCrawler
{
    class CGetHotelCount: CDataCrawler
    {
        // ----- Protected methods -----

        protected override void Handle()
        {
            var node = document.DocumentNode.SelectSingleNode(".//*[@id='hc_bc']/ul[1]/li[2]/span[1]");
            try
            {
                if (node != null)
                {
                    string strCount = node.InnerText.Replace(",", "");
                    count = Convert.ToInt32(strCount);
                }
            }
            catch (Exception ex)
            {
                count = 0;
            }
        }

        // This field stores the number of hotel.
        protected int count;

        // ----- Public methods -----

        // Properties

        public CGetHotelCount()
            : base("http://www.hotelscombined.com/Place/Vietnam.htm")
        {
        }

        public int Count
        {
            get { return count; }
        }
    }
}
